<?php
require_once(SITE_ROOT."/includes/page/Page.php");
require_once(SITE_ROOT."/configs/career_config.php");
require_once(SITE_ROOT."/configs/movietype_config.php");
require_once(SITE_ROOT."/includes/tools/AjaxFileUploader.inc.php");
require_once(SITE_ROOT."/includes/application/SignApplication.php");
//todo some implates

/**
 * 登录、注册类
 * 功能：实现所有注册、登录相关功能、处理相关session（数据库记录式）,初始化注册与登录功能等。
 * time：2008-10-26
 * author：王照暄
 */
class Sign extends Page {
	public function getTemplate() {
        return $this->template;
    }
	//阅读声明与资料填写
	private function sign_Signup(){
		global $gSmarty;
		$gSmarty->display("member/sign/signup.html");
	}
	
	private function sign_maidou1(){
		global $gSmarty,$career_config;
		$userId = $_SESSION['G_USERID'];
		$uploadDirectory = SITE_ROOT."/static/user/".$userId."/face";
		$ajaxFileUploader = new AjaxFileuploader($uploadDirectory);
		$upinput =  $ajaxFileUploader->showFileUploader('id1');
		$gSmarty->assign("upinput",$upinput);
		$gSmarty->assign("career",$career_config);
		$gSmarty->display("member/sign/signup_maidou_1.dwt");
	}
	private function sign_maidou2(){
		global $gSmarty,$movieType_config;
		$gSmarty->assign("movetype",$movieType_config);
		$gSmarty->display("member/sign/signup_maidou_2.dwt");
	}
	private function sign_maidou3(){
		global $gSmarty;
		$gSmarty->display("member/sign/signup_maidou_3.dwt");
	}
	private function sign_maidou4(){
		global $gSmarty;
		$gSmarty->display("member/sign/signup_maidou_4.dwt");
	}
	
	private function sign_signin(){
		global $gSmarty;
		$gSmarty->display("member/sign/signin.dwt");
	}
	private function postLogin(){
		global $gSmarty;
		$username = $_POST['users'];
		$passwd = $_POST['pwds'];
		$preUrl = $_GET['redirectUrl'];
		$user = Wzx::getElementObject(0);
		$rtn = $user->postLogin($username,$passwd);
		if($rtn == "0"){
			$preUrl == "" ? $this->redirect("/modules/space.php") : $this->redirect($preUrl);
		}else{
			echo $rtn;
		}
	}
	
	
	public function  prapare(){
		$act = $_GET['act'];
		if( $act == "" ){
			$this->sign_Signup();
		}elseif($act == "maidou_1"){
			$this->sign_maidou1();
		}elseif($act=="maidou_2"){
			$this->sign_maidou2();
		}elseif ($act=="maidou_3"){
			$this->sign_maidou3();
		}elseif ($act=="maidou_4"){
			$this->sign_maidou4();
		}elseif($act=="signin"){
			$this->sign_signin();
		}elseif ($act=="postlogin"){
			$this->postLogin();
		}
	}
}

?>